<style lang="scss" scoped>
	.content {

		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}


	.footer {
		width: 100%;
		background-color: white;
		position: fixed;
		bottom: 0;
		left: 0;
		border-top: 1px solid #cccccc;
		padding-left: 30rpx;
		padding-right: 30rpx;
		z-index: 100;
	}


	.sbtn {
		width: 176rpx;
		height: 88rpx;
		border: 2rpx solid #dee2ee;
		border-radius: 46rpx;
	}

	.lbtn {
		width: 484rpx;
		margin-right: 0;
	}

	.tip {
		color: #98A5B3;
		padding: 0 30rpx;
		width: 100%;
	}

	.list {
		width: 688rpx;
		padding: 25rpx 0;
		opacity: 1;
		background: #ffffff;
		border-radius: 24rpx;
		box-shadow: 0rpx 6rpx 12rpx 0rpx rgba(0, 0, 0, 0.08);
		margin-top: 30rpx;

		.job {
			border-bottom: 2rpx solid #f5f7fa;
			padding: 20rpx 0;

			.h2 {
				display: inline-block;
				color: #07c160;
				width: 140rpx;
				position: relative;
			}

			.h2:before {
				content: '';
				width: 8rpx;
				height: 8rpx;
				background-color: #07C160;
				position: absolute;
				top: 50%;
				left: 0;
				transform: translate(-10rpx, -50%);
				border-radius: 50%;
			}
		}

		.job:last-child {
			border-bottom: none;
		}

		.c999 {
			display: inline-block;
			width: 140rpx;
			color: $gray;
		}

		.h1 {
			border-left: 6rpx solid #409eff;
			padding: 0 20rpx;
			margin-bottom: 20rpx;
		}

		.contains {
			width: 100%;
			padding: 20rpx;
			border-top: 1px solid #eee;

			.text {
				width: 100%;
				line-height: 60rpx;

				.between-flex {
					>view {
						width: 50%;
					}
				}
			}
		}
	}

	.mbtn {
		width: 330rpx;
		height: 88rpx;
		opacity: 1;
		border: 2rpx solid #dee2ee;
		border-radius: 46rpx;
		margin: 30rpx 0;
	}

	.mbtn2 {
		width: 330rpx;
		height: 88rpx;
		opacity: 1;
		border: 2rpx solid #409eff;
		border-radius: 46rpx;
		margin: 30rpx 0;
	}
</style>

<template>
	<view class="content">
		<!-- 基础信息 -->
		<view class="tip between-flex m-top30 f28">
			<view>创建人:{{info.createUserName}}</view>
			<view>创建时间: {{info.createTime}}</view>
		</view>
		<view class="list textColor">
			<view class="f28 bold h1 textColor">会议信息</view>
			<view class="contains between-flex">
				<view class="text">
					<view><span class="c999">会议主题</span><span>{{info.title}}</span></view>
					<view><span class="c999">会议议题</span><span>{{info.subject}}</span></view>
					<view><span class="c999">会议类型</span><span>{{info.type | meetingtype}}</span></view>
					<view v-if="info.time"><span class="c999">会议时间</span><span>{{info.time.substring(0, 10)}}
							{{info.meetingTimes[0].startTime}}-{{info.meetingTimes[info.meetingTimes.length-1].endTime}}</span>
					</view>
					<view><span class="c999">会议室</span><span>{{meetingroom.name}}</span></view>
					<view><span class="c999">会议地址</span><span>{{meetingroom.address}}</span></view>
					<view v-if="info.hosts"><span class="c999">主持人</span><span>{{$getNames(info.hosts)}}</span></view>
					<view><span class="c999">参会人数</span><span>{{info.attends?info.attends.length:'0'}}人</span></view>
					<view class="flex" v-if="info.attends">
						<view class="c999">参会人员</view>
						<view style="width:500rpx;">{{$getNames(info.attends)}}</view>
					</view>


				</view>

			</view>
		</view>
		<view class="list textColor">
			<view class="f28 bold h1 textColor">更多信息</view>
			<view class="contains between-flex">
				<view class="text">

					<view><span class="c999">所属项目</span><span>{{project.title}}</span></view>
					<view v-if="info.audits"><span class="c999">审核人</span><span>{{$getNames(info.audits)}}</span></view>
					<view class="between-flex" v-for="item,index in info.person" :key="index">
						<view><span class="c999">联系人</span><span>{{item.person}}</span></view>
						<view><span class="c999" style="white-space: nowrap;">联系电话</span><span
								style="white-space: nowrap;">{{item.phone}}</span></view>
					</view>

				</view>

			</view>
		</view>
		<view v-if="flag">
			<view class="list textColor">
				<view class="f28 bold h1 textColor">会议纪要</view>
				<view class="contains between-flex">
					<view class="text">
						<view><span class="c999">记录人</span><span>{{$getNames(info.hosts)}}</span></view>
						<view><span class="c999">到会人员</span><span>{{$getNames(info.users)}}</span></view>
						<view><span class="c999">会议纪要</span><span>{{info.summary}}</span></view>
					</view>

				</view>
			</view>
			<view class="list textColor" v-if="task.length>0">
				<view class="f28 bold h1 textColor">任务</view>
				<view class="contains between-flex" style="padding-top: 0;padding-bottom: 0;">
					<view class="text">
						<view class="job" v-for="item,index in task" :key="index">
							<view><span class="h2">任务{{index+1}}</span><span>{{item.taskName}}</span></view>
							<view class="between-flex">
								<view><span class="c999">责任人</span><span>{{item.leaderUser | user}}</span></view>
								<view><span class="c999" style="white-space: nowrap;">结束时间</span><span
										style="white-space: nowrap;">{{item.planEndDate?item.planEndDate:'-'}}</span></view>
							</view>
						</view>
						
					</view>

				</view>
			</view>
		</view>


		<view class="center-flex" style="margin-top: 30rpx;" v-if="info.summary">
			<view @click="flag=!flag" class="align-flex blue">{{flag?'收起纪要':'会议纪要'}}
				<view :style="flag?'transform: rotate(-180deg);':'' ">
					<u-icon name="arrow-down" color="#409EFF" size="28"></u-icon>
				</view>
			</view>
		</view>
		<view class="space"></view>
		<view class="footer between-flex paddingBottom" v-if="type==0">
			<view class="sbtn center-flex textColor bold f32" @click="$back">返回</view>
			<view class="lbtn" @click="$navTo(PagesHuiYiRouterConfig.Minutes+'?id='+id)">编写会议纪要</view>
		</view>
		<view class="footer between-flex paddingBottom" v-if="info.time&&type==2&&showbtn&&isEnd()">
			<view class="mbtn2 center-flex blue f32 bold" @click="showPopup=true">驳回</view>
			<view class="mbtn2 center-flex blue f32 bold" @click="accpetOrder()">通过</view>
		</view>
		<view class="footer between-flex paddingBottom" v-if="info.time&&type==3&&showbtn&&isEnd()">
			<view class="mbtn center-flex textColor f32 bold" @click="delOrder">撤销</view>
			<view class="mbtn2 center-flex blue f32 bold" @click="$navTo(PagesHuiYiRouterConfig.Reserve+'?type=edit&meetingId='+id)">编辑</view>
		</view>

		<u-popup mode="bottom" v-model="showPopup" :closeable="true" borderRadius="20">
			<reject v-if="type==2" :meetingId="id" @submit="showbtn=false;goback()"></reject>
		</u-popup>

	</view>
</template>

<script>
	import reject from '@/pagesHuiyi/operation/reject.vue'
		import PagesHuiYiRouterConfig from  '@/pagesHuiyi/routerConfig.js'
	export default {
		components: {
			reject
		},
		data() {
			return {
				PagesHuiYiRouterConfig,
				navheight: 0,
				head: this.$head,
				type: 0, //0我主持的1我参会的2带我审核3我创建的
				showPopup: false,
				showReview: false,
				flag: false,
				id: 0,
				info: {},
				process: {},
				meetingroom: {},
				project: {},
				showbtn: true ,//底部按钮是否显示
				task: [],
			}
		},
		onLoad(e) {
			this.type = e.type
			console.log(this.type)
			this.id = e.id
			

		},
		onShow() {
			this.getInfo()
		},
		methods: {
			isEnd() {
				var startTime =`${this.info.time.substring(0, 10)} ${this.info.meetingTimes[0].startTime}`
				
					startTime = startTime.replace(/-/g, '/');
				startTime = (new Date(startTime).getTime())
				var nowTime = new Date().getTime()
				console.log(startTime - nowTime)
				console.log(startTime)
				if (nowTime < startTime) {
					return true  //会议未开始，可以操作
				} else {
					return false //会议已开始，不可操作
				}


			},
			delOrder() {

				uni.showModal({
					title: '确认撤销会议吗？',
					success: (res) => {
						if (res.confirm) {
							this.$pop.ajaxPost('/bus/busMeeting/delete', {
								id: this.id
							}).then(res => {
								if (res.code == 0) {
									this.$msg('操作成功')
									this.showbtn = false

									this.goback()
								} else {
									this.$msg(res.msg)
								}
							})
						}
					}
				})
			},
			accpetOrder() {

				uni.showModal({
					title: '确认通过审核吗？',
					success: (res) => {
						if (res.confirm) {
							this.$pop.ajaxPost('/bus/meetingProcess/addProcess', {
								meetingId: this.id,
								processState: 'audit_meeting',
								operState: 'meeting_pass',
								remark: ''
							}).then(res => {
								if (res.code == 0) {
									this.$msg('通过成功')
									this.showbtn = false

									this.goback()
								} else {
									this.$msg(res.msg)
								}
							})
						}
					}
				})
			},
			goback() {
				// let pages = getCurrentPages(); //获取所有页面栈实例列表
				// let nowPage = pages[pages.length - 1]; //当前页页面实例
				// let prevPage = pages[pages.length - 2]; //上一页页面实例
				// if (prevPage.$vm.current) {
				// 	prevPage.$vm.current = 2
				// }
				setTimeout(() => {
					uni.navigateBack({

					})
				}, 1500)

			},
			getInfo() {
				this.$pop.ajaxPost('/bus/busMeeting/getById', {
					id: this.id
				}).then(res => {
					this.info = res.body
					this.getMeetingroom()
					this.getProcess()
						
					if( this.info.itemCode){
						this.getProject()
					}
					if (this.info.taskId) { //有任务
						this.getTask()
					}
					
				})
			},
			getTask() {
				var ids = this.info.taskId
				ids = ids.split(',')
				ids.forEach(item=>{
					this.$pop.ajaxPost('/bus/taskInfo/details', {
						id: item
					}).then(res=>{
						this.task=res.body
					})
				})
			},
			getMeetingroom() {
				this.$pop.ajaxPost('/bus/busMeetingRoom/getById', {
					id: this.info.meetingRoomId
				}).then(res => {
					this.meetingroom = res.body
				})
			},
			getProcess() {
				this.$pop.ajaxPost('/bus/meetingProcess/getProcessList', {
					meetingId: this.id
				}).then(res => {
					this.process = res.body
				})
			},
			getProject() {
				this.$pop.ajaxPost('/busItemInfo/getPage', {
					pageNum: 1,
					pageSize: 1,
					temp: 'all',
					query: this.info.itemCode
				}).then(res => {
					this.project = res.body.list[0]
				})
			}

		}
	}
</script>
